//公告详情
import React, {Component} from 'react'
import {View, Text, WebView} from 'react-native'
import Loading from '../common/loading'
import styles from "../../configs/styles";
import {I18n} from "../../configs/enumeration";
import {GetBroadcastApi} from "../../configs/api";
import HTMLView from 'react-native-htmlview';


class broadcastShow extends Component {

  constructor(props) {
    super(props);
    const params = props.navigation.state.params;
    this.state = {
      broadcast_id: params.broadcast_id,
      data: [],
      loading: true,
    };
  }

  componentDidMount() {
    this.getData()
  }

  getData = () => {
    GetBroadcastApi(this.state.broadcast_id).then((data) => {
      this.setState({
        data: data.broadcast_attrs,
        loading: false
      })
    })
  };

  render() {
    const {loading, data} = this.state;
    if (loading) {
      return <Loading/>
    } else {
      return (
        <View style={{alignItems: 'center'}}>

          <View style={{flexDirection: 'row'}}>
            <View style={styles.kv_center}><Text>主题</Text></View>
            <View style={styles.kv_center}><Text>{data.title}</Text></View>
          </View>

          <View style={{flexDirection: 'row'}}>
            <View style={styles.kv_center}><Text>发布部门</Text></View>
            <View style={styles.kv_center}><Text>{data.department_name}</Text></View>
          </View>

          <View style={{flexDirection: 'row'}}>
            <View style={styles.kv_center}><Text>公告类别</Text></View>
            <View style={styles.kv_center}><Text>{data.classify_text}</Text></View>
          </View>

          <View style={{flexDirection: 'row'}}>
            <View style={styles.kv_center}><Text>发布人</Text></View>
            <View style={styles.kv_center}><Text>{data.user_name}</Text></View>
          </View>

          <View style={{flexDirection: 'row'}}>
            <View style={styles.kv_center}><Text>发布时间</Text></View>
            <View style={styles.kv_center}><Text>{data.created_at}</Text></View>
          </View>

          <View style={{flexDirection: 'row'}}>
            <View style={styles.kv_center}><Text>相关附件</Text></View>
            <View style={styles.kv_center}><Text>{data.file_url}</Text></View>
          </View>

          <View style={{flexDirection: 'row'}}>
            <HTMLView value={data.content}/>
          </View>

        </View>
      )
    }
  }
}

export default broadcastShow